//砍树
https://www.luogu.com.cn/problem/P1873#ide

#include <iostream>
using namespace std;

typedef long long LL;
const int max_N = 1e6 + 10;
LL arr[max_N];
LL N, M;

LL sum(LL height)
{
    LL count = 0;
    for (LL i = 0; i < N; i++)
    {
        if (arr[i] > height) count += arr[i] - height;
    }
    return count;
}

int main()
{
    cin >> N >> M;
    for (LL i = 0; i < N; i++)
    {
        cin >> arr[i];
    }

    LL left = 0, right = 2e9;
    while (left < right)
    {
        LL mid = left + (right - left + 1) / 2;
        LL tmp = sum(mid);
        if (tmp >= M)
        {
             left = mid;
        }
        else 
        {
            right = mid - 1;
        }
    }

    cout << left << endl;
    return 0;
}